/**  \file NewUser.qml
\brief Login form / New user registration

Price My House for Nokia mobile platforms.

\author © 2011 Enrico Miglino / Tech Consulting (enrico.miglino@ovi.com)
\author "Evimin Fiyati Price My House" is protected by the copyright law
\author Distributed under the LGPL 3.0 license.
\date 2011

\par Licensing notes

    "Price My House" is free software: you can redistribute it
    and/or modify it under the terms of the Lesser GNU General Public License
    as published by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    "Price My House" is distributed in the hope that it
    will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    Lesser GNU General Public License for more details.

    You should have received a copy of the Lesser GNU General Public License
    along with "Price My House".
    If not, see <http://www.gnu.org/licenses/>.

*/

import QtQuick 1.0
import "../Qt-Complex" as Framework
import "../Qt-Complex/Geometry.js" as Geometry
import "PriceMyHouse.js" as Jmain

// Form for new user quick registration
Item {
    id: newuser

    width: parent.width; height: parent.height

    property string labelUser: ""
    property string labelPassword: ""
    property string buttonCreate:  ""

    signal newuserClicked;

    // Screen area background
    Rectangle {
        id: loginBackground; color: Jmain.appBackground;
        width: parent.width; height: parent.height
    }

    // Background + form elements
    Rectangle {
        id: formbackground

        anchors.top: parent.top
        anchors.topMargin: Geometry.getFormBorder() * 4;
        width: parent.width * 0.85; height: parent.height
        anchors.horizontalCenter: parent.horizontalCenter
        color: "#d1cece"; border.color: "#eeeeee";
        radius: Geometry.getRadius();
        border.width: Geometry.getFormBorder();

        // Input fields
        Column {
            id: fields
            spacing: Geometry.getFieldSpacing()
            width: formbackground.width

            anchors {
                top: formbackground.top; topMargin: Geometry.getFormBorder()
                horizontalCenter: formbackground.horizontalCenter
            }

            Text {
                id: lblUser
                wrapMode: TextEdit.NoWrap; height: Geometry.getFieldHeight()
                font.pointSize: Geometry.getFontPoints(); text: newuser.labelUser
            }
            InputField {
                id: fieldUser
                width: parent.width - Geometry.getFormBorder() * 2;
                height: Geometry.getFieldHeight();
            }
            Text {
                id: lblPwd
                wrapMode: TextEdit.NoWrap; height: Geometry.getFieldHeight()
                font.pointSize: Geometry.getFontPoints(); text: newuser.labelPassword
            }
            InputField {
                id: fieldPwd
                width: parent.width - Geometry.getFormBorder() * 2;
                height: Geometry.getFieldHeight()
                echoCharacter: TextInput.Password
            }
        }

        // Choice buttons
        Row {
            id: buttons

            spacing: Geometry.getButtonSpacing();
            width: formbackground.width * 0.70

            // Anchors buttons to the bottom of the screen
            anchors {
                bottom: formbackground.bottom
                bottomMargin: Geometry.getFormBorder() * 2
                horizontalCenter: parent.horizontalCenter
            }

            // load the new user creation
            Framework.Loader {
                id: btnNewUser

                width: buttons.width
                height: Geometry.getButtonHeight()
                theme: "PMH";
                obj: "Button";
                obj_string: newuser.buttonCreate
                onClicked: { newuser.newuserClicked() }
            }
        }
    }
}
